package com.huazi.www.frontdesk.servlet;

import com.huazi.www.frontdesk.javaBase.DepartmentInfo;
import com.huazi.www.frontdesk.javaBase.PageInfo;
import com.huazi.www.frontdesk.javaBase.QueueInfo;
import com.huazi.www.frontdesk.service.impl.FrontdeskCardServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 转诊Servlet
 */
public class QueuePageServlet extends HttpServlet {
    FrontdeskCardServiceImpl frontdeskCardService = new FrontdeskCardServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/thml;charse=UTF-8");//修改respones域的编码集
        req.setCharacterEncoding("UTF-8");//修改request域的编码集
        String id = req.getParameter("id");//获取传过来的值id
        String curr = req.getParameter("curr");//获取当前码curr
        if (id == null || id == "") {
            id = "0";
        }
        if (curr == null || curr == "") {
            curr = "1";
        }
        //得到科室的所有科目 医生
        List<DepartmentInfo> list = frontdeskCardService.list();//new frontdeskCardService类list方法
        req.setAttribute("kelist", list);//保存list对象

        PageInfo<QueueInfo> pagequeue = frontdeskCardService.pagequeue(Integer.parseInt(id), Integer.parseInt(curr));//new frontdeskCardService类pagequeue方法


        req.setAttribute("pagequeue", pagequeue);//保存pagequeue对象
        req.setAttribute("patientId", id);//保存id对象
        req.getRequestDispatcher("frontdesk/queue.jsp").forward(req, resp);//转发至queue.jsp页面
    }

}
